<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>交换变量值</title>
    <script>
        var str1 = "红";
        var str2 = "白";
        console.log(str1);
        console.log(str2);
        console.log('---------------');
        var temp;
        temp = str1;
        str1 = str2;
        str2 = temp;
        console.log(str1);
        console.log(str2);
    </script>
</head>

<body>

</body>

</html>